﻿/// <reference path="../../mapparola.client/scripts/typings/knockout/knockout.d.ts" />

module Mapparola.Core {

    export class Discussion {

        public Token: string;
        public ParentToken: string;
        public Location: Mapparola.Core.Point;
        public CreatedDate: Date;
        public Responses: Discussion[];
        public IsPersonal: boolean;
        public Username: string;
        public AccountToken: string;

        public _text: string;

        constructor() {
            this.Responses = [];
        }

        public GetText(): string {
            return this._text;
        }

        public SetText(txt: string): void {
            this._text = txt;
        }

        public static FromDatabaseObject(messageInstance: any): Discussion {
            var discussion: Discussion = new Discussion();

            discussion.Token = messageInstance.token;
            discussion.SetText(messageInstance.message);
            discussion.Location = messageInstance.location;
            discussion.IsPersonal = false;
            discussion.CreatedDate = messageInstance.created_time;
            discussion.AccountToken = messageInstance.t_accounts_token;
            return discussion;
        }


    }
}

declare var exports: any;
if (typeof exports != 'undefined') {
    exports.Discussion = Mapparola.Core.Discussion;
}